/**
 * @projectName study-note
 * @package Flyweight
 * @className Flyweight.WebsiteFactory
 */
package Flyweight;

import java.util.HashMap;

/**
 * WebsiteFactory
 * @description 网站工厂类
 * @author answer_wx
 * @date 2022/7/6 14:53
 * @version 1.0
 */
public class WebsiteFactory {
    private HashMap<String, AbstractWebsite> websiteMap = new HashMap();

    public AbstractWebsite getWebsiteName(String name) {
        if (!websiteMap.containsKey(name)) {
            websiteMap.put(name, new ConcreteWebsite(name));
        }
        return websiteMap.get(name);
    }

    public int countWebsite() {
        return websiteMap.size();
    }
}